#include "aerial\Game\GameObject\Equipment\Propeller.h"

#include "aerial\Game\GameObject\FlyObject\FlyObject.h"

#include <iostream>

using namespace std;

Propeller::Propeller(FlyObject* _host, float _scale = 1.f, float _offset = 0.f)
	:host(_host), scale(_scale), offset(_offset)
{
	hgeParticleSystem* par = hgeResMan->GetParticleSystem("ps.propeller");
	parPropeller=new hgeParticleSystem(&par->info);
	parPropeller->info.fParticleLifeMax = 0.05f;

	parPropeller->Fire();
}

void Propeller::rendPropeller()
{
	parPropeller->Render();
}

bool Propeller::update(float dt)
{
	parPropeller->info.nEmission = (int)( scale * (int)host->GetSpeed().LengthSquared() );
	parPropeller->MoveTo(
		host->GetPosition().x - host->GetDirection().x * offset,
		host->GetPosition().y - host->GetDirection().y * offset);
	parPropeller->Update(dt);
	return false;
}